import { stringify } from 'qs';
import request from '../utils/request';

export async function colorFetch(params) {
  return request(`/basedata/color?${stringify(params)}`, {
    method: 'get',
  });
}
export async function typeFetch(params) {
  return request(`/basedata/type?${stringify(params)}`, {
    method: 'get',
  });
}
export async function seriesFetch(params) {
  return request(`/basedata/series?${stringify(params)}`, {
    method: 'get',
  });
}
export async function fetchTbox(params) {
  return request(`/basedata/tbox/${params}`, {
    method: 'get',
  });
}
export async function findVehicleProfile(params) {
  return request(`/basedata/findprofile/${params}`, {
    method: 'get',
  });
}
export async function brandFetch() {
  return request('/basedata/findbrandbylogin');
}
export async function fetchProject() {
  return request('/basedata/findprojectbylogin');
}
export async function fetchTboxByDeviceid(params) {
  return request(`/basedata/findtboxbydeviceid/${params}`, {
    method: 'GET',
  });
}
export async function fetchVehicleByVin(params) {
  return request(`/basedata/findvehiclebyvin/${params}`, {
    method: 'GET',
  });
}
export async function fetchSimByMsisdn(params) {
  return request(`/basedata/findsimbymsisdn/${params}`, {
    method: 'GET',
  });
}
export async function searchSeries(params) {
  return request(`/basedata/series/${params.name}`, {
    method: 'GET',
  });
}

export async function searchTypeList(params) {
  return request(`/basedata/typeList?${stringify(params)}`, {
    method: 'get',
  });
}
export async function searchSeriesList(params) {
  return request(`/basedata/seriesList?${stringify(params)}`, {
    method: 'get',
  });
}
export async function searchColorList(params) {
  return request(`/basedata/colorList?${stringify(params)}`, {
    method: 'get',
  });
}

export async function findFactory() {
  return request('/basedata/findfactory', {
    method: 'get',
  });
}

export async function findFactoryBrand() {
  return request('/basedata/findfactorybrand', {
    method: 'get',
  })
  // .then(() => ([{ dataValue: '东风风神', dataKey: 'DFPV' }]));
}

export async function findDealerByFactory(params) {
  return request(`/basedata/finddealerbyfactory?${stringify(params)}`, {
    method: 'get',
  });
}

export async function findDealerByBrand(params) {
  return request(`/basedata/finddealerbybrand?${stringify(params)}`, {
    method: 'get',
  });
}

export async function seriesLabels() {
  return request('/basedata/findSeriesLabels', {
    method: 'GET',
  });
}
export async function brandSeriesLabels(params) {
  return request(`/basedata/findserieslabelsbybrand?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function fetchDealerByLogin() {
  return request('/basedata/finddealerbylogin');
}
export async function fetchTemplate(params) {
  return request(`/basedata/importtemplate/find?${stringify(params)}`, {
    method: 'get',
  });
}

export async function findVehicleActiveList() {
  return request('/basedata/findvehicleactivelist');
}
export async function seriesByBrandCode() {
  return request('/basedata/brandCodes/series', {
    method: 'GET',
  });
}

export async function findVehicleBatchActiveList() {
  return request('/basedata/findvehiclebatchactivelist');
}

export async function findVehicleActiveListByDealer() {
  return request('/basedata/finddealeractivelist');
}

export async function findDicData() {
  return request('/basedata/dicdata', {
    method: 'GET',
  });
}

export async function findSeriesByids(params) {
  return request('/basedata/seriesbybrandids', {
    method: 'POST',
    body:params,
  });
}

//多个项目获得多个车系
export const findSeriesByProjects = async params =>
  request('/basedata/findseriesbyprojects', {
    method: 'POST',
    body:params,
  });

export async function findRedisData() {
  return request('/basedata/findredisdata', {
    method: 'GET',
  });
}
//根据品牌查项目
export async function findProjectIdsByBrandCode(params) {
  return request(`/basedata/findProjectIdsByBrandCode?${stringify(params)}`, {
    method: 'get',
  });
}
//根据品牌查经销商
export async function findDealerByBrandCode(params) {
  return request(`/basedata/findDealerByBrandCode?${stringify(params)}`, {
    method: 'get',
  });
}

//查询当前用户品牌和项目的关系，用于内容管理
export async function findProjectByUser() {
  return request(`/basedata/find/project/login`, {
    method: 'get',
  });
}